---
title: "文件同步命令rsync"
date: 2020-4-3
categories:
- linux
tags:
---

<div id="content">
<div id="table-of-contents">
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#orgd123e7a">语法：</a>
<ul>
<li><a href="#org5ec8094">本地文件同步</a></li>
<li><a href="#org5cd4f47">使用远程shell程序例如(ssh)</a></li>
<li><a href="#org63b0848">与远程rsync服务同步文件</a></li>
<li><a href="#org2bf5fb8">例如</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div class="outline-2" id="outline-container-orgd123e7a">
<h2 id="orgd123e7a">语法：</h2>
<div class="outline-text-2" id="text-orgd123e7a">
</div>
<div class="outline-3" id="outline-container-org5ec8094">
<h3 id="org5ec8094">本地文件同步</h3>
<div class="outline-text-3" id="text-org5ec8094">
<p>
rsync [OPTION…] SRC… [DEST]
</p>
<p>
SRC和DEST中都不包含冒号时进行本地文件同步
</p>
</div>
</div>
<div class="outline-3" id="outline-container-org5cd4f47">
<h3 id="org5cd4f47">使用远程shell程序例如(ssh)</h3>
<div class="outline-text-3" id="text-org5cd4f47">
<p>
Pull: rsync [OPTION…] [USER@]HOST:SRC… [DEST]
Push: rsync [OPTION…] SRC… [USER@]HOST:DEST
</p>
</div>
</div>
<div class="outline-3" id="outline-container-org63b0848">
<h3 id="org63b0848">与远程rsync服务同步文件</h3>
<div class="outline-text-3" id="text-org63b0848">
<p>
Pull: rsync [OPTION…] [USER@]HOST::SRC… [DEST]
rsync [OPTION…] rsync://[USER@]HOST[:PORT]/SRC… [DEST]
Push: rsync [OPTION…] SRC… [USER@]HOST::DEST
rsync [OPTION…] SRC… rsync://[USER@]HOST[:PORT]/DEST
</p>
<p>
Usages with just one SRC arg and no DEST arg will list the source files instead of copying.
</p>
</div>
</div>
<div class="outline-3" id="outline-container-org2bf5fb8">
<h3 id="org2bf5fb8">例如</h3>
<div class="outline-text-3" id="text-org2bf5fb8">
<p>
常用选项-a与-rlptgoD相同
</p>
<div class="org-src-container">
<pre class="src src-sh"><span style="font-weight: bold; font-style: italic;"># </span><span style="font-weight: bold; font-style: italic;">同步远程music目录到本地music目录</span>
rsync -av user@192.168.0.103::music/ music/
</pre>
</div>
</div>
</div>
</div>
</div>
<div class="status" id="postamble">
<p class="date">Date: 2020-4-3</p>
<p class="author">Author: gdem1320</p>
<p class="validation"><a href="http://validator.w3.org/check?uri=referer">Validate</a></p>
</div>
